﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using IBatisNet.DataMapper;

namespace WS
{
    using WS.Domain;
    /// <summary>
    /// Summary description for WS_Lophoc
    /// </summary>
    [WebService(Namespace = "WS")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class WS_Lophoc : System.Web.Services.WebService
    {
        ISqlMapper sqlMapper;
        List<Lophoc> list;

        public WS_Lophoc()
        {
            sqlMapper = Mapper.Instance();
        }

        #region Web Method Lớp học
        
            [WebMethod]
            public List<Lophoc> SelectLophoc() 
            {
                list = (List<Lophoc>)sqlMapper.QueryForList<Lophoc>("getLophoc", null);
                return list;
            }

            [WebMethod]
            public bool InsertLophoc(Lophoc Lophoc)
            {
                try
                {
                    sqlMapper.Insert("insertLophoc", Lophoc);
                    return true;
                }
                catch (Exception) { return false; }
            }

            [WebMethod]
            public bool UpdateLophoc(Lophoc Lophoc)
            {
                try
                {
                    sqlMapper.Update("updateLophoc", Lophoc);
                    return true;
                }
                catch (Exception) { return false; }
            }

            [WebMethod]
            public bool DeleteLophoc(int id)
            {
                try
                {
                    sqlMapper.Delete("deleteLophoc", id);
                    return true;
                }
                catch (Exception) { return false; }
            }

            [WebMethod]
            public List<Lophoc> Check_Malop(Lophoc lp)
            {
                try
                {
                    list = (List<Lophoc>)sqlMapper.QueryForList<Lophoc>("check_Malop", lp);
                    return list;
                }
                catch (Exception) { return null; }

            }

        #endregion
    }
}
